/************************************************************************/
/*Copyright (c) James Zhao 2007,2008
/*This file is part of AdminOverlay.
/*AdminOverlay is free software: you can redistribute it and/or modify
/*it under the terms of the GNU General Public License as published by
/*the Free Software Foundation, either version 3 of the License, or
/*(at your option) any later version.
/*
/*AdminOverlay is distributed in the hope that it will be useful,
/*but WITHOUT ANY WARRANTY; without even the implied warranty of
/*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
/*GNU General Public License for more details.
/*
/*You should have received a copy of the GNU General Public License
/*along with Foobar.  If not, see <http://www.gnu.org/licenses/>.                                                                     */
/*************************************************************************/
#include "ListItem.h"

ListItem::ListItem( QString myText, int x, int y, int width, int height): 
	UIPanel(x,y,width,height)
{
	text = myText;
	textVisual = new TextVisual(text, 0xFFAEAEAE,  globalPos.x(), globalPos.y(),
		width, height, TextVisualType_Title, 15);
	TopColor(0xCF222620);
	BottomColor(0xCF222620);
}
ListItem::~ListItem(void)
{
	
}
void ListItem::draw( LPDIRECT3DDEVICE9 device)
{
	if(hasBoundsChanged)
	{		
		textVisual->X(GlobalPos().x() + 2);
		textVisual->Y(GlobalPos().y() + 2);
		textVisual->Width(width);
		textVisual->Height(height);
	}
	//draw ui panel first so textvisual can draw on top of it
	UIPanel::draw(device);
	textVisual->draw(device);
}
void ListItem::IsSelected( bool val )
{
	isSelected = val;
	TopColor(isSelected ? 0xDF2E332B : 0xCF222620);
	BottomColor(isSelected ? 0xDF2E332B : 0xCF222620);
}

bool ListItem::IsSelected() const
{
	return isSelected;
}

TextVisual * ListItem::TxtVisual() const
{
	return textVisual;
}

void ListItem::TxtVisual( TextVisual * val )
{
	textVisual = val;
}